package com.treasure.common.types;

import com.treasure.common.exception.ParameterException;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

/**
 * @author sunhongmin
 * @date 2023/10/20 21:48
 * @description
 */
public class FileName {

    @Getter
    private final String value;

    public FileName(String value) {
        if (StringUtils.isBlank(value)) {
            throw new ParameterException("未获取到文件名称，请重新尝试上传");
        }
        this.value = value;
    }

    /**
     * 文件后缀
     */
    public String getFileSuffix() {
        return value.substring(value.lastIndexOf("."));
    }


}
